# -*- utf-8 -*-
from sqlalchemy import Column, Integer, String, ForeignKey, create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship

Base = declarative_base()


class Seller(Base):
    """卖家信息"""
    __tablename__ = 'seller'
    # "地点", "联系人", "电话", "RapNet账号", "RapNet地址"
    id = Column(Integer, primary_key=True, autoincrement=True)
    address = Column(String(255), comment="地点")
    availability = Column(String(255), comment="联系人")
    phone_number = Column(String(255), comment="电话")
    rapnet_account = Column(String(255), comment="RapNet账号")
    homepage = Column(String(255), comment="卖家主页")
    name = Column(String(255), comment="卖家昵称")


class Price(Base):
    """价格信息"""
    __tablename__ = 'price'
    id = Column(Integer, primary_key=True, autoincrement=True)
    stock_lot_number = Column(String(255), comment="库存批号")
    availability = Column(String(255), comment="可用性")
    location = Column(String(255), comment="钻石的地点")
    stock_number = Column(String(255), comment="库存号码")
    price_per_card = Column(String(255), comment="每卡价格_现金")
    rap_percentage = Column(String(255), comment="Rap百分比_现金")
    total = Column(String(255), comment="总数")


class Diamond(Base):
    """钻石信息"""
    __tablename__ = 'diamond'
    id = Column(Integer, primary_key=True, autoincrement=True)
    shape = Column(String(255), comment="形状")
    size = Column(String(255), comment="尺寸")
    color = Column(String(255), comment="颜色")
    clarity = Column(String(255), comment="净度")
    cut = Column(String(255), comment="切割")
    polished = Column(String(255), comment="打磨")
    symmetry = Column(String(255), comment="对称度")
    fluorescence = Column(String(255), comment="荧光")
    depth = Column(String(255), comment="深度")
    table = Column(String(255), comment="台面")
    size_unit = Column(String(255), comment="尺寸")
    key_features = Column(String(255), comment="关键特征")
    supplier_comments = Column(String(255), comment="供应商评论")
    bottom_tip = Column(String(255), comment="底尖")
    waist = Column(String(255), comment="腰")
    crown = Column(String(255), comment="冠")
    pavilion = Column(String(255), comment="亭部")
    processed = Column(String(255), comment="处理的")
    inscription = Column(String(255), comment="题词")
    ratio = Column(String(255), comment="比率")
    star_facet_length = Column(String(255), comment="星型刻面长")
    impurities = Column(String(255), comment="杂质")
    color_tone = Column(String(255), comment="色调")
    brand = Column(String(255), comment="牌子")
    shape_in_report = Column(String(255), comment="报告中的形状")
    comments_in_the_report = Column(String(255), comment="报告中的形状")

    price_id = Column(Integer, ForeignKey("price.id"), comment="价格的外键")
    price = relationship("Price", backref='diamond')

    seller_id = Column(Integer, ForeignKey("seller.id"), comment="卖家的外键")
    seller = relationship("Seller", backref='diamond')


if __name__ == '__main__':
    engine = create_engine('mysql+pymysql://root:123456@localhost/rapnet?charset=utf8')
    Base.metadata.create_all(engine)
